package com.software.loginregister.api;

import com.software.loginregister.entity.Comment;
import com.software.loginregister.entity.Like;
import com.software.loginregister.entity.Result;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface CommentApi {
    @POST("api/comments")
    Call<Result<Comment>> postComment(@Body Comment comment);

    @GET("api/comments")
    Call<Result<List<Comment>>> getComments(@Query("worksId") Long worksId);

    @POST("api/comments/like/{commentId}")
    Call<Result<Map<String, Object>>> toggleCommentLike(
            @Path("commentId") Integer commentId,
            @Query("userId") Integer userId
    );

    // 新增的API方法
    @GET("api/comments/{commentId}")
    Call<Result<Comment>> getCommentById(@Path("commentId") Integer commentId);

    @DELETE("api/comments/{commentId}")
    Call<Result<Void>> deleteComment(@Path("commentId") Integer commentId);

    @PUT("api/comments/{commentId}")
    Call<Result<Comment>> updateComment(
            @Path("commentId") Integer commentId,
            @Body Comment comment
    );

    @POST("api/likes")
    Call<Result<Like>> addLike(@Query("userId") Integer userId, @Query("targetId") Integer targetId, @Query("targetType") String targetType);

    @HTTP(method = "DELETE", path = "api/likes", hasBody = true)
    Call<Result<Void>> removeLike(@Query("userId") Integer userId, @Query("targetId") Integer targetId, @Query("targetType") String targetType);

    @GET("api/likes/count")
    Call<Result<Integer>> getLikeCount(@Query("targetId") Integer targetId, @Query("targetType") String targetType);

    @GET("api/likes/status")
    Call<Result<Boolean>> isLiked(@Query("userId") Integer userId, @Query("targetId") Integer targetId, @Query("targetType") String targetType);

}

